<?php

include './DragGraphicVerificationCode.php';

//初始化
$DragGraphicVerificationCode = new DragGraphicVerificationCode();
$DragGraphicVerificationCode->imgRoute = './code'; //背景图地址注释了会自动去OSS那边获取


//userId  是一个动态变得参数


if($_GET['type'] == 'BgImage'){
    //大图
    $DragGraphicVerificationCode->BgImage([
        'key'=>'userId',  //唯一标识
        'overtime'=>1, //单位分钟
    ]);
}

if($_GET['type'] == 'BlockImage'){
    //方块图形
    $DragGraphicVerificationCode->BlockImage('userId');
}

if($_GET['type'] == 'checkCode'){

    //验证码
    $result = $DragGraphicVerificationCode->checkCode('userId',$_POST['code']);
    if($result){
        echo '{"data":null,"message":"验证成功","code":"1"}';
    }else{
        echo '{"data":null,"message":"验证码错误","code":"0"}';
    }
}
